using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Configuration;
using Microsoft.Practices.PageFlow.Utils;
using System.Globalization;

namespace WCSFContrib.PageFlow.Xml.Configuration
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
    public class NavigationGraphConfigurationElementCollection : ConfigurationElementCollection
    {
        public NavigationGraphConfigurationElementCollection()
        {
        }

        protected override bool ThrowOnDuplicate
        {
            get { return true; }
        }

        public void Add(NavigationGraphConfigurationElement navigationGraph)
        {
            BaseAdd(navigationGraph);
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]
        public bool Contains(string navigationGraphName)
        {
            Guard.ArgumentNotNullOrEmptyString(navigationGraphName, "navigationGraphName");
            return base.BaseGet(navigationGraphName.ToLower(CultureInfo.CurrentCulture)) != null;
        }

        public override ConfigurationElementCollectionType CollectionType
        {
            get { return ConfigurationElementCollectionType.BasicMap; }
        }

        protected override string ElementName
        {
            get { return "navigationGraph"; }
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new NavigationGraphConfigurationElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((NavigationGraphConfigurationElement)element).Name.ToLower(CultureInfo.CurrentCulture);
        }

        public NavigationGraphConfigurationElement this[int index]
        {
            get { return (NavigationGraphConfigurationElement)base.BaseGet(index); }
        }

        public new NavigationGraphConfigurationElement this[string navigationGraphName]
        {
            get 
            {
                Guard.ArgumentNotNullOrEmptyString(navigationGraphName, "navigationGraphName");

                return (NavigationGraphConfigurationElement)base.BaseGet(navigationGraphName.ToLower(CultureInfo.CurrentCulture)); 
            }
        }
    }
}